#include<iostream>
#include<cstring>
/*
* https://www.luogu.com.cn/problem/CF1650A
* author:liuqx
* 2024/7/18
* 13:23-13:31
*/
using namespace std;
int main()
{
	int times;
	cin >> times;
	for (int index = 0; index < times; index++)
	{
		string str;
		cin >> str;
		bool flag = false;
		char cha;
		cin >> cha;
		for (int i = 0; i < str.length(); i+=2)
		{
			if (str[i] == cha)
			{
				flag = true;
				cout << "YES\n";
				break;
			}
		}
		if (!flag)
		{
			cout << "NO\n";
		}
	}
	return 0;
}